package cn.jinjimi.app.controller.event.NoticeEvent;

import com.google.gson.annotations.SerializedName;
import cn.jinjimi.app.store.entity.NoticeEntity;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by lforxeverc on 2017/7/19.
 */

public class NoticeRewardCardEvent extends NoticeEvent {
    public List<NoticeEntity> mNoticeEntities;
    public List<Coupon> mCoupons;

    public NoticeRewardCardEvent(int state) {
        super(state);
    }

    public NoticeRewardCardEvent(List<NoticeEntity> noticeEntities) {
        super(noticeEntities);
        // 按创建时间重新排序
        Collections.sort(noticeEntities, new Comparator<NoticeEntity>() {
            @Override
            public int compare(NoticeEntity o1, NoticeEntity o2) {
                return (int) (o1.startTime - o2.startTime);
            }
        });
        mNoticeEntities = noticeEntities;
        mCoupons = NoticeEntity.getCoupons(noticeEntities);
    }

    public static class Coupon {
        @SerializedName("img_url")
        public String imgUrl;
        @SerializedName("link_url")
        public String linkUrl;
    }
}
